Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Panel Data- Working with the ID`s

    Hello, Statalisters

    I am working with an Unbalanced Panel Data with information about sales, capital stock, raw materials, workforce, etc at the firm-level. I need to generate a dummy that takes tha value of 1 for the whole firm (observations with the same ID) when at least one of the observations in the firm satisfies a condition: for instance, sales_growth>100000.

    I will really appreciate your help, best regards



    Jairo

  • #2
    Code:
    bysort id: egen dummy=max(sales_growth>100000)
    See

    Code:
    help egen

    Comment


    • #3
      Thank you for your answer. I just saw the egen manual but I can't find anything using if statement.

      HTML Code:
      bysort firma: gen dummy=1 if ingresos_21 != ingresos_ciiu
      i tried something like this but it just assigned 1 to the observations (not the whole firm with at least one observation) for which the conditional was TRUE.

      Comment


      • #4
        Code:
        bysort firma: egen dummy=max(ingresos_21 != ingresos_ciiu)
        You need egen with the max() function and not gen. The following FAQ by Nick Cox provides a better explanation.

        https://www.stata.com/support/faqs/d...ble-recording/

        Comment

        Working...
        X